
#ifndef __FLASHTASK_H
#define	__FLASHTASK_H

#include <stdint.h>
#include "dataproc.h"
#include "rtctime.h"
#include "mytype.h"
#include "simp_log.h"
#include "app_def.h"

#ifdef	__cplusplus
extern "C" {
#endif
	
#ifdef   _FLASH_TASK_MODULE_
#define  MY_EXT
#else
#define  MY_EXT  extern
#endif  

typedef enum
{
    USB_CMD_NONE=0,
    USB_CMD_READ=0xAA11,
    USB_CMD_SEARCH_WITH_RS_AMOUNT=0xAA22,
    USB_CMD_SEARCH_WITH_TIME=0xAA33,
} usb_cmd_type;

#define FLASH_OPT_CLR       0x5511
#define FLASH_OPT_RS_LOG    0x5522
#define FLASH_OPT_HEAD      0x5533
#define FLASH_OPT_MID       0x5544
#define FLASH_OPT_TAIL      0x5555

typedef struct
{
    uint32_t st;
    uint8_t flash_id[8];
    
    uint32_t cmd_get[2];
    
    uint32_t ver1;
    uint32_t hist_dat[16];
    uint32_t ver2[2];
    uint32_t hist_rslog[4];
    uint32_t ver3[2];
    
    volatile struct
    {
        usb_cmd_type req;
        
        //搜索控制
        sig_time_type search_time;
        uint32_t search_rs_amount;
        int8_t search_mode;
        
        //搜索结果
        int32_t search_site;
        uint32_t search_addr;
        
        //读取控制
        uint32_t read_addr;
        uint32_t read_len;
        uint8_t *read_pdat;
    } usb_cmd;
    
    
} flash_opt_type;


MY_EXT flash_opt_type flash_opt;

#undef MY_EXT

#ifdef	__cplusplus
}
#endif

#endif	/* __FLASHTASK_H */
